<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: zhangkai
// +----------------------------------------------------------------------
use think\facade\Route;
Route::rule('Index/index$', '/Index/index')->middleware(\app\common\middleware\RateLimiting::class,['limit'=>100]);
Route::post('User/login$', '/User/login');
// 需要登录的路由
Route::group(function(){
    // 权限
    Route::get('auth/getTree', '/Auth/getTree');
    // 角色操作
    Route::get('role/getList', '/Role/getList')->middleware(\app\admin\middleware\ApiPermission::class,['role-list']);
    Route::get('role/getOption', '/Role/getOption');
    Route::post('role/add', '/Role/add')->middleware(\app\admin\middleware\ApiPermission::class,['role-add']);
    Route::patch('role/update', '/Role/update')->middleware(\app\admin\middleware\ApiPermission::class,['role-update']);
    Route::delete('role/del', '/Role/del')->middleware(\app\admin\middleware\ApiPermission::class,['role-delete']);
    // 用户
    Route::get('User/current', '/User/current');
    Route::delete('User/logout', '/User/logout');
    Route::get('user/getList', '/User/getList')->middleware(\app\admin\middleware\ApiPermission::class,['user-list']);
    Route::post('user/add', '/User/add')->middleware(\app\admin\middleware\ApiPermission::class,['user-add']);
    Route::patch('user/update', '/User/update')->middleware(\app\admin\middleware\ApiPermission::class,['user-update']);
    Route::patch('user/editPassword', '/User/editPassword')->middleware(\app\admin\middleware\ApiPermission::class,['user-password-edit']);
    Route::delete('user/del', '/User/del')->middleware(\app\admin\middleware\ApiPermission::class,['user-delete']);
    // oss
    Route::get('oss/getOssToken', '/oss/getOssToken');
})->middleware(\app\admin\middleware\AuthToken::class);

// CodeGeneration
Route::group(function(){
    // 获取表目录
    Route::get('codeGeneration/getTableList', '/CodeGeneration/getTableList');
    // 获取表字段信息
    Route::post('codeGeneration/getTableColumns', '/CodeGeneration/getTableColumns');
    // 代码生成
    Route::post('codeGeneration/generateCode', '/CodeGeneration/generateCode');
    // 获取所有的模块名
    Route::get('codeGeneration/getAllModules', '/CodeGeneration/getAllModules');
})->middleware(\app\common\middleware\RateLimiting::class,['limit'=>1]);